package com.sm.healthy.base

import android.view.Gravity.CENTER
import com.lishuaihua.toast.ToastUtils
import me.hgj.jetpackmvvm.base.BaseApp
import me.jessyan.autosize.AutoSizeConfig
import me.jessyan.autosize.unit.Subunits


class App : BaseApp() {

    companion object {
        lateinit var instance: App
        val database: AppDatabase by lazy {
            AppDatabase.getInstance(instance)
        }
    }

    override fun onCreate() {
        super.onCreate()

        instance = this
        ToastUtils.init(this)
        ToastUtils.setGravity(CENTER, 0, 0)
        configUnits()
    }

    private fun configUnits() {
        AutoSizeConfig.getInstance().unitsManager
            .setSupportDP(false)
            .setSupportSubunits(Subunits.MM)
        AutoSizeConfig.getInstance()
            .setCustomFragment(true)
    }
}
